/*
 * RhoAvg.h
 *
 *  Created on: Jun 8, 2011
 *      Author: marchi
 */

#ifndef RHOAVG_H_
#define RHOAVG_H_
#include "Phi.h"
#include <iostream>
using std::cout;
using std::endl;

class RhoAvg {
protected:
	int n;
	Rho * avg;
public:
	RhoAvg(){
		n=0;
		avg=NULL;
	}
	void Accumulate(Rho & y){
		if(avg) (*avg)+=y;
		else avg=new Rho(y);
		n++;
	}
	Rho getavg(){
		Rho temp(*avg);
		temp=temp/static_cast<double>(n);
		return temp;
	}
	int getN(){return n;}
	virtual ~RhoAvg(){avg->Rho::~Rho();delete avg;};
};

#endif /* RHOAVG_H_ */
